/*
 * SecondLevelCacheLoader
 *
 * Copyright (c) 2010 ValueCommerce Co.,Ltd. All Rights Reserved
 */
package see.fa.trial.util;

import see.fa.trial.dao.UserDao;
import see.fa.trial.model.User;

import java.util.LinkedList;
import java.util.List;

/**
 * SecondLevelCacheLoader.
 *
 * @version $Id: $
 */
public class SecondLevelCacheLoader {

    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void execute() {
        System.out.println("[" + this + "]***************************************************************************");
        System.out.println("loaded " + loadAllUsers().size() + " number of users.");
        System.out.println("*****************************************************************************************");
    }

    public List<User> loadAllUsers() {
        List<User> users = new LinkedList<User>();
        for(Long id : userDao.getAllIds()) {
            users.add(userDao.get(id));
        }
        return users;

    }

}